import appservice from "./request";
const baseURL = "account"

export function login(data): Promise<any> {
  return appservice.post({
    url: `${baseURL}/login`,
    data: data,
  });
}

export function register(data): Promise<any> {
  return appservice.post({
    url: `${baseURL}/registe`,
    data: data,
  });
}

export function clearCookie(): Promise<void> {
  return appservice.get({
    url: `${baseURL}/clear`,
  });
}

export function sendEmailCode(email:string): Promise<void> {
  return appservice.post({
    url: `${baseURL}/send-code/${email}`,
  });
}

export function validateEmailCode(email:string, code:string): Promise<ResetTokenDto> {
  return appservice.post({
    url: `${baseURL}/vertify-code`,
    data:{
      email: email,
      code: code
    }
  });
}

export function resetPassword(data): Promise<void> {
  return appservice.put({
    url: `${baseURL}/reset-password`,
    data: data,
  });
}


export class ResetTokenDto{
  token: string;
}


export class RegisterRequestModel {
  userName: string;
  password: string;
  nickName: string;
  email: string;
  phoneNumber: string;
  gender: number;
}
